/*
 * @Date: 2024-04-03 09:24:04
 * @LastEditors: bingkui.wu
 * @LastEditTime: 2024-04-07 10:46:33
 * @Description: 教材处理接口
 */

import ajax from './ajax';

/**
 * 获取全部教材
 */
export const getCategories = () => {
    const options = {
        'method': 'GET',
        'url': `/book/get-category-grade`
    }
    return ajax.fetch(options);
}

/**
 * 通过年级id，获取单元列表
 * @param {number} gradeId 年级Id
 * @returns 
 */
export const getUnitsByGradeId = (categoryId, gradeId) => {
    const options = {
        'method': 'GET',
        'url': `/book/get-unit-by-grade-id?gradeId=${gradeId}&categoryId=${categoryId}`
    }
    return ajax.fetch(options);
}


/**
 * 获取单元对象
 * @param {string} unitId 单元id
 * @returns 返回unit对象
 */
export const getUnit = (unitId) => {
    const options = {
        'method': 'GET',
        'url': `/book/get-unit-detail?unitId=${unitId}`
    }
    return ajax.fetch(options);
}

/**
 * 通过wordId获取对应的word对象
 * @param {Array} wordIds wordId集合
 */
export const getWordsById = (wordIds) => {
    const options = {
        'method': 'POST',
        'url': `/book/get-words`,
        data: { wordIds }
    }
    return ajax.fetch(options);
}
